home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / EXAMPLE0.ASM < prev    next >
Assembly Source File  |  1995-01-12  |  7KB  |  303 lines

  1. ; 386POWER example program #0.
  2. ; Install a mouse driver, compile, and run.
  3. ; When run, use the left mouse button to draw. Any key exits.
  4.         .386p
  5. code32 segment para public use32
  6.        assume cs:code32,ds:code32
  7.  
  8. include 386power.inc
  9. include 386keyb.inc
  10. include 386timer.inc
  11. include 386file.inc
  12. include 386arg.inc
  13.  
  14. public  _Main
  15.  
  16. CR equ 0dh
  17. LF equ 0ah
  18. DBLANK = 07200720h ; black bg, white fg,blank space
  19. ; DATA
  20. ex_text         db      'TEST ZERO for 386POWER',CR,LF
  21.                 db      'Testing startup, FILE I/0 & Keyboard',CR,LF
  22.                 db      'PRESS ESC TO EXIT',0
  23. txt_mem         db      'AVAILABLE EXTENDED MEMORY',CR,LF
  24.                 db      'AVAILABLE DOS MEMORY',0
  25.  
  26. fl_mem          db      'SIZE OF HELLO.TXT FILE',0
  27. tt_mem          db      'TEXT CONTAINED INTO HELLO.TXT:',0
  28. man_text        db      'SYSTEM TYPE:',0
  29. pro_text        db      '  PROCESSOR:',0
  30. optext          db      ' _____Command__line__text_____',CR,LF
  31.                 db      'Filenames:      Options:',0
  32. systypestr      db      'VCPI','DPMI'
  33. cputypestr      db      '8086',' 186',' 286',' 386',' 486',' 586'
  34. hextuff         db      '0123456789ABCDEF'
  35. d_text          db      8 dup(0)
  36. fname           db      'hello.txt',0
  37. rkbtext         db      'RAW KEYBOARD TEST:',0
  38. esctext         db      'Press & release keys ',0
  39.  
  40. ; CODE
  41.  
  42. CHROW  = 160
  43. MAXCOL   = 80
  44. MAXROW   = 25
  45. CHCELL   = 2
  46. textbase dd 0B8000h
  47.  
  48. PutText:  ; put max. ECX chars pointed by ESI
  49.           ; to screen location pointed by EDI
  50.           ; with attr AH
  51.         push ecx
  52.         push edi
  53.         add edi,textbase
  54.         mov ebp,edi
  55. XPutText:        
  56.         lodsb
  57.         cmp al,0
  58.         je CHend
  59.         cmp al,CR
  60.         jne noCR
  61.         mov edi,ebp
  62.         jmp nxCH
  63. noCR:   cmp al,LF
  64.         jne noLF
  65.         add ebp,CHROW
  66.         add edi,CHROW
  67.         jmp nxCH
  68. noLF:                
  69.         stosw
  70. nxCH:   dec ecx     
  71.         jne XPutText
  72. CHend:  pop edi
  73.         pop ecx
  74.         ret
  75.         
  76.  
  77. ;----------------------
  78. Bin2Hex:; edx = dword to convert to hex
  79.         ; edi = ptr to 8byte "converted dword" destination
  80.         push ebx
  81.         push ecx
  82.         push edi
  83.         push edx
  84.         xor ebx,ebx
  85.         mov ecx, 8
  86.         add edi, 7
  87.         std
  88. txpit:        
  89.         mov ebx,edx
  90.         and ebx,0Fh
  91.         mov al,[ebx+hextuff]
  92.         stosb
  93.         shr edx,4
  94.         dec ecx
  95.         jne txpit
  96.         pop edx
  97.         pop edi
  98.         pop ecx
  99.         pop ebx
  100.         cld
  101.         ret
  102.         
  103. d2text macro
  104.         push edi
  105.         mov edi,offset d_text
  106.         call Bin2Hex
  107.         pop edi
  108.        endm
  109.  
  110.  
  111.  
  112. zaptext:
  113.         push ecx
  114.         push eax
  115.         push edi
  116.         mov ecx,(80*25)/2    ; text screen size in dwords
  117.         mov eax,DBLANK       ; character and attributes
  118.         mov edi,textbase
  119.         rep stosd
  120.         pop edi
  121.         pop eax
  122.         pop ecx
  123.         ret
  124. ;═════════════════════════════════════════════════════════════════════════════
  125. _Main:  sti  ; enable interrupts (386P disables them)
  126.         mov al,10h
  127.         mov V86ax,0003 ; text mode 80 columns, 16 colors
  128.         call _ExecINT
  129.         mov eax,_Code32Base  ;
  130.         sub textbase,eax     ; convert to to code32 offset
  131.  
  132.         call zaptext
  133.  
  134.         mov edi,(CHROW*4)
  135.         mov ah,7
  136.         mov ecx,-1
  137.         mov esi,offset optext
  138.         call PutText
  139.  
  140.         call _ArgInit           ; initialize command line scanner
  141.         mov edi,(CHROW*6)
  142.         mov ah,14
  143.         mov ecx,-1
  144.      argc:
  145.         call _ArgFile           ; read filename
  146.         cmp byte ptr [esi],0
  147.         je nofarg
  148.         call PutText
  149.         add edi,CHROW
  150.         jmp argc
  151. nofarg:        
  152.         mov edi,(CHROW*6+30)
  153.      optc:
  154.         call _ArgOpt           ; read option
  155.         cmp byte ptr [esi],0
  156.         je noopt
  157.         call PutText
  158.         add edi,CHROW
  159.         jmp optc
  160. noopt:  ; system type info
  161.         mov edi,(50*CHCELL)    ; put type of system
  162.         mov esi,offset man_text
  163.         mov ecx,-1
  164.         mov ah,14
  165.         call PutText
  166.         movzx esi,_386Man
  167.         lea esi,[esi*4+systypestr]
  168.         add edi,15*CHCELL
  169.         mov ecx,4
  170.         mov ah,15
  171.         call PutText
  172.         ; cpu type info
  173.         mov edi,CHROW+(50*CHCELL) ; put cpu type
  174.         mov esi,offset pro_text
  175.         mov ecx,-1
  176.         mov ah,14
  177.         call PutText
  178.         movzx esi,_CPUPower
  179.         lea esi,[esi*4+cputypestr]
  180.         add edi,15*CHCELL
  181.         mov ecx,4
  182.         mov ah,15
  183.         call PutText
  184.  
  185.         ;  available memory info text
  186.  
  187.         mov edi,18
  188.         mov esi,offset txt_mem
  189.         mov ecx,-1
  190.         mov ah,13
  191.         call PutText
  192.         ; high mem.
  193.         mov edx,_HiMemTop
  194.         sub edx,_HiMemBase
  195.         d2text
  196.         mov edi,0
  197.         mov esi,offset d_text
  198.         mov ecx,8
  199.         mov ah,12
  200.         call PutText
  201.  
  202.         ; low mem.
  203.         mov edx,_LoMemTop
  204.         sub edx,_LoMemBase
  205.         d2text
  206.         mov edi,CHROW
  207.         mov esi,offset d_text
  208.         mov ecx,8
  209.         mov ah,12
  210.         call PutText
  211.  
  212.  
  213.         mov esi, offset fname
  214.         call _FLoad
  215.         
  216.         pushad
  217.         mov edx,eax
  218.         d2text
  219.         
  220.         mov edi,(CHROW*2)
  221.         mov esi,offset d_text
  222.         mov ecx,8
  223.         mov ah,11
  224.         call PutText
  225.         
  226.         mov edi,18+(CHROW*2)
  227.         mov esi,offset fl_mem
  228.         mov ecx,-1
  229.         mov ah,11
  230.         call PutText
  231.         
  232.         popad
  233.         
  234.         mov ecx,eax
  235.         
  236.         cmp eax,-1
  237.         je noputthis
  238.         mov esi,_HiMemBase
  239.         mov edi,(CHROW*15)
  240.         mov ah,5
  241.         call PutText
  242.         
  243.         mov edi,(CHROW*14)
  244.         mov esi,offset tt_mem
  245.         mov ecx,-1
  246.         mov ah,7
  247.         call PutText
  248.         
  249. noputthis:       
  250.         mov edi,(CHROW*22)+(40*CHCELL)
  251.         mov esi,offset ex_text
  252.         mov ecx,-1
  253.         mov ah,10
  254.         call PutText
  255.         
  256.         call _KeybInst
  257.         
  258.         mov edi,(CHROW*3)+100
  259.         mov ah,7
  260.         mov ecx,-1
  261.         mov esi,offset rkbtext
  262.         call PutText
  263.         mov edi,(CHROW*4)+100
  264.         mov ah,7
  265.         mov ecx,-1
  266.         mov esi,offset esctext
  267.         call PutText
  268.         
  269. kkey:        
  270.         call _WaitKey
  271.         mov edi,(0b8000h+(CHROW*5)+120)
  272.         sub edi,_Code32Base
  273.         mov esi,eax
  274.         mov ebx,16
  275. inlup:        
  276.         push edi
  277.         mov ecx,8
  278. glup:        
  279.         lodsb
  280.         mov dx,1720h
  281.         test al,01
  282.         jz zogg
  283.         mov dx,1740h
  284. zogg:   mov [edi],dx
  285.         add edi,2
  286.         dec ecx
  287.         jne glup
  288.         pop edi
  289.         add edi,CHROW
  290.         dec ebx
  291.         jne inlup
  292.         sub esi,128
  293.         cmp byte ptr [esi+_ESC],KPRESSED
  294.         je thend
  295.         jmp kkey        
  296. thend:        
  297.         call zaptext
  298.         jmp _Exit
  299.  
  300. code32  ends
  301.         end
  302.  
  303.